//
//  MyTabarViewController.swift
//  testSwift
//
//  Created by taoge on 2018/3/30.
//  Copyright © 2018年 FT. All rights reserved.
//

import UIKit

class MyTabarViewController: UITabBarController {

    override func viewDidLoad() {
        
        super.viewDidLoad()
        creatUI()
        
    }
    func creatUI(){
       tabBar.tintColor = UIColor.blue
       tabBar.barTintColor = UIColor.cyan
        
       self.addChildVC(childVC:ViewController(), childTitle: "TAOGE", imageName: "", selectedImageName: "")
        self.addChildVC(childVC:SecongViewController(), childTitle: "XIAO", imageName: "", selectedImageName: "")
        self.addChildVC(childVC:ThreeViewController(), childTitle: "LAO", imageName: "", selectedImageName: "")
        
    }
    /// 添加子控制器
    private func addChildVC(childVC: UIViewController, childTitle: String, imageName: String, selectedImageName:String)
    {
        let navigation = UINavigationController(rootViewController: childVC)
        navigation.navigationBar.tintColor = UIColor.white //item 字体颜色
        navigation.navigationBar.barTintColor = UIColor.yellow //背景颜色
        let dict:NSDictionary = [NSAttributedStringKey.foregroundColor: UIColor.white,NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 18)]
        //标题颜色
        navigation.navigationBar.titleTextAttributes = dict as? Dictionary
        childVC.title = childTitle
        childVC.tabBarItem.tag = 1
        childVC.tabBarItem.image = UIImage(named: imageName)?.withRenderingMode(.alwaysOriginal)
        childVC.tabBarItem.selectedImage = UIImage(named: selectedImageName)?.withRenderingMode(.alwaysOriginal)
        self.addChildViewController(navigation)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
